#include "widget.h"
#include "ui_widget.h"
#include"gamecontrol.h"
#include<QKeyEvent>
#include<QDebug>


Widget* Widget::widget = nullptr;

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    this->setFixedSize(1347,1009);

    widget = this;



 }

Widget::~Widget()
{
    delete ui;
}
//添加按键
void Widget::keyPressEvent(QKeyEvent* event)
{
    switch(event->key())
    {
    case Qt::Key_W:
    case Qt::Key_S:
    case Qt::Key_A:
    case Qt::Key_D:
    case Qt::Key_5:
    case Qt::Key_1:
    case Qt::Key_2:
    case Qt::Key_3:
        GameControl::Instance()->mKeyList.append(event->key());
        break;

    }
}
//移除按键
void Widget::keyReleaseEvent(QKeyEvent* event)
{
    if(GameControl::Instance()->mKeyList.contains(event->key()))
    {
       GameControl::Instance()->mKeyList.removeOne(event->key());

    }

}

 //测试
void Widget::mousePressEvent(QMouseEvent *event)
{
    QPoint localPos = event->pos();
    qDebug()<<"坐标"<<localPos;
 }



// 添加箱子（添加钻石）（写按钮）添加游戏时间计时器 音频修改 主页面背景 成功窗口 失败提示 整理代码
